<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use League\Fractal\Manager;
use League\Fractal\Resource\Collection;
use App\Models\Picture;
class Brand extends Model
{

    /**
     * 表名称
     * @var $table ;
     */
    protected $table = 'brand';

    /**
     * 主键
     * @var $primaryKey
     */
    protected $primaryKey = 'brand_id';


    /**
     * 时间戳   禁止
     * @var bool $timestamps
     */
    public $timestamps = false;
    protected $appends = array('mobile_brand_logo');
    /**
     * 自动填充字段
     * @var $fillable
     */

    protected $fillable = ['brand_name', 'brand_logo', 'm_brand_logo', 'brand_desc', 'sort_order', 'is_recommend'];

    function getMobileBrandLogoAttribute(){

        $brand_logo = $this->getAttribute('m_brand_logo');

        if(!$brand_logo){
            return null;
        }
        return Picture::find($brand_logo)->url;


    }


}
